import cv2                                      # 调用摄像头拍摄照片


# 调用摄像头拍摄照片
def get_photo(camera_index):
    camera = cv2.VideoCapture(camera_index)           # 开启摄像头
    f, frame = camera.read()               # 将摄像头中的一帧图片数据保存
    return camera, frame


def close_camera(camera):
    camera.release()


if __name__ == '__main__':
    camera, frame = get_photo()                 # 开启摄像头获取照片
    cv2.imwrite('current_frame.jpg', frame)
    close_camera(camera)


